package nccloud.fct.ap.utils;

import com.yonyou.ucf.mdf.util.BIPUtil;
import com.yonyou.ucf.mdf.util.HttpClientUtil;
import nc.vo.pub.BusinessException;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class YhtHttpUtil {

    public YhtHttpUtil() {
        throw  new UnsupportedOperationException("Not supported yet.");
    }

    public static Properties getYfkProperties() throws BusinessException {
        Properties prop = new Properties();
        InputStream inputStream = YhtHttpUtil.class.getResourceAsStream("yht.properties");
        try {
            prop.load(inputStream);
        } catch (IOException e) {
            throw new BusinessException(e);
        }
        return prop;
    }

    public static String getToken() throws BusinessException {
        // 获取token
        String accessToken = BIPUtil.getAccessToken(getYfkProperties().getProperty("yht_domainurl") +
                        getYfkProperties().getProperty("token_url"),
                getYfkProperties().getProperty("appKey"),
                getYfkProperties().getProperty("appSecret"));
        if (accessToken == null || "".equals(accessToken)) {
            throw new BusinessException("获取accessToken出错");
        }
        return accessToken;
    }

//    return HttpClientUtil.doPost(yfkURI,null, reqParams, reqBody);
}
